Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ChatWithTools provider #167

Merged
merged 9 commits into from
Dec 19, 2024
Merged

Add ChatWithTools provider #167

merged 9 commits into from
Dec 19, 2024

Conversation

julien-nc
Copy link
Member

@julien-nc julien-nc commented Dec 10, 2024

This will be used by the Agency feature which uses the tooling capabilities of LLMs.

This provider can be tested in the assistant because it dynamically generates a form for the task type (we will hide this task type later).

One small issue: We enforce all the input params but we might wanna set the tool_message (The result of tool calls in the last interaction).
If we give a fake/useless value to the OpenAI API, the request fails because the tool_message does not come after a "tool call" message.
To be discussed.

To test this provider, just replace $toolMessage = $input['tool_message']; by $toolMessage = null; in the provider and pass a dummy tool_message value in the form.
As all input fields have to be defined, also add at least one message in the "chat history".
You can use that in the "tools" input:

[{
    "type":"function",
    "function":{
        "description":"get the weather in a city",
        "name":"get_city_weather"
    }
}]

So if you ask for the weather in the city, you should get a tool call as a response. If not, you should get a classic response.

Signed-off-by: Julien Veyssier <[email protected]>
Signed-off-by: Julien Veyssier <[email protected]>
@julien-nc julien-nc force-pushed the enh/noid/chat-with-tools branch from 6993b75 to 05a9e8b Compare December 10, 2024 16:42
@@ -137,6 +138,7 @@ public function translate(?string $fromLanguage, string $toLanguage, string $tex

if ($this->openAiAPIService->isUsingOpenAi() || $this->openAiSettingsService->getChatEndpointEnabled()) {
$completion = $this->openAiAPIService->createChatCompletion($this->userId, $adminModel, $prompt, null, null, 1, PHP_INT_MAX);
$completion = $completion['messages'];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

summaries will need adjustment too, after edward's PR, I think

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, let's see who merges first.

…, expect a list of JSON object strings as history

Signed-off-by: Julien Veyssier <[email protected]>
Signed-off-by: Julien Veyssier <[email protected]>
Copy link
Member

@marcelklehr marcelklehr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@marcelklehr marcelklehr merged commit 9150fc9 into main Dec 19, 2024
7 checks passed
@julien-nc julien-nc mentioned this pull request Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants